﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WPF45"
                    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
                    xmlns:Common="clr-namespace:Snipps.Infrastructure" xmlns:Selectors="clr-namespace:Snipps.Selectors"
                    xmlns:Filters="clr-namespace:Snipps.ViewModels.Filters"
                    xmlns:custom="clr-namespace:Snipps.Infrastructure.Behaviors">


    <ResourceDictionary.MergedDictionaries>
        <Common:SharedResourceDictionary Source="/Snipps;component/Resources/BaseControlStyles/ListBoxItemStyle.xaml" />
    </ResourceDictionary.MergedDictionaries>


    <Selectors:CompletionListItemDataTemplateSelector x:Key="completionListItemDataTemplateSelector" />


    <DataTemplate DataType="{x:Type Filters:CompletionListViewModel}">

        <ListView BorderThickness="0"
                  IsTabStop="False"
                  ItemContainerStyle="{StaticResource {x:Type ListBoxItem}}"
                  ItemTemplateSelector="{StaticResource completionListItemDataTemplateSelector}"
                  ItemsSource="{Binding FilteredItems}"
                  ScrollViewer.VerticalScrollBarVisibility="Auto"
                  SelectedItem="{Binding SelectedItem,
                                         Mode=TwoWay}">

            <i:Interaction.Behaviors>
                <custom:ScreollIntoViewBehavior />
            </i:Interaction.Behaviors>

            <i:Interaction.Triggers>
                <i:EventTrigger EventName="PreviewMouseDoubleClick">
                    <cmd:EventToCommand Command="{Binding ActivateSelectedItemCommand}" />
                </i:EventTrigger>
            </i:Interaction.Triggers>

            <ListView.ItemsPanel>
                <ItemsPanelTemplate>
                    <VirtualizingStackPanel />
                </ItemsPanelTemplate>
            </ListView.ItemsPanel>

        </ListView>
    </DataTemplate>


</ResourceDictionary>